﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class admin_admin : System.Web.UI.MasterPage
{
    private DataSet objDataSet;

    protected void Page_Load(object sender, EventArgs e)
    {
        LoadLoaiSanPham();
        LoadNhaSanXuat_LoaiSanPham();
        LoadRole();
    }

    public DataSet NewRoleDataSet()
    {
        DataSet objDataSet = new DataSet();
        DataTable objDataTable = objDataSet.Tables.Add("RoleTable");

        DataColumn objDataColumn;

        objDataColumn = new DataColumn("Role", Type.GetType("System.String"));
        objDataTable.Columns.Add(objDataColumn);

        return objDataSet;
    }
    private void LoadRole()
    {
        if (Session["RoleForUser"] != null)
        {
            if (Session["RoleForUser"].ToString().Equals("Admin"))
            {
                objDataSet = NewRoleDataSet();
                DataRow myDataRow = objDataSet.Tables["RoleTable"].NewRow();
                myDataRow["Role"] = Session["RoleForUser"];

                objDataSet.Tables["RoleTable"].Rows.Add(myDataRow);

                repRole.DataSource = objDataSet.Tables[0];
                repRole.DataBind();
            }
        }
    }
    private void LoadLoaiSanPham()
    {
        LoaiSanPhamBUS objLoaiSP = new LoaiSanPhamBUS(TGDDConfiguration.DbConnectionString);
        try
        {
            objDataSet = objLoaiSP.SelectLoaiSanPhamAll();

            repLoaiSanPham_SP.DataSource = objDataSet.Tables[0];
            repLoaiSanPham_SP.DataBind();
        }
        catch (System.Exception e)
        {

        }
    }

    private void LoadNhaSanXuat_LoaiSanPham()
    {
        NhaSanXuatBUS objNhaSX_LoaiSP = new NhaSanXuatBUS(TGDDConfiguration.DbConnectionString);
        try
        {
            objDataSet = objNhaSX_LoaiSP.SelectNhaSanXuatLoaiSanPham();

            repNhaSanXuat_LoaiSanPham_SP.DataSource = objDataSet.Tables["SelectNhaSanXuatLoaiSanPham"];
            repNhaSanXuat_LoaiSanPham_SP.DataBind();
        }
        catch (System.Exception e)
        {

        }
    }

    /*private void LoadSanPhamByLoaiSP_NSX()
    {
        SanPhamBUS objSanPham = new SanPhamBUS(TGDDConfiguration.DbConnectionString);
        try
        {
            objDataSet = objSanPham.SelectSanPhamByLoaiSP_NSX();
            repSanPham.DataSource = objDataSet.Tables["SelectSanPhamByLoaiSP_NSX"];
            repSanPham.DataBind();
        }
        catch (System.Exception e)
        {
        	
        }
    }*/
}
